<?php
declare(strict_types=1);

use support\command\phinx\MigrationBaseClass;

final class CreateApiDescsTable extends MigrationBaseClass
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * https://book.cakephp.org/phinx/0/en/migrations.html#the-change-method
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function change(): void
    {
        $this->schema->create('api_descs', function (Illuminate\Database\Schema\Blueprint $table) {
            $table->increments('id');
            $table->string('key')->unique()->comment('接口唯一键');
            $table->string('title')->default('')->comment('接口名称');
            $table->string('summary')->default('')->comment('描述');
            $table->string('route')->comment('路径');
            $table->string('method')->comment('方法');
            $table->string('group_id')->comment('所属分组id');
            $table->text('params')->nullable()->comment('返回参数说明:json');
            $table->text('headers')->nullable()->comment('请求头');
            $table->text('return_params')->nullable()->comment('返回字段说明');
            $table->text('return_headers')->nullable()->comment('返回字段说明');
            $table->text('returns')->nullable()->comment('返回数据示例:json');
            $table->integer('weigh')->default(100)->comment('权重');
        });
    }
}
